<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false"%>
<%@ taglib uri="http://java.fckeditor.net" prefix="FCK"%>
<%@ include file="../../common/inc.jsp" %>
<%@ include file="../../common/loading.jsp" %>
<%@ include file="../common/session.jsp" %>

<%
request.setCharacterEncoding("UTF-8");
String now = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
ChannelInfoDao clDao = new ChannelInfoDao();
LanguageInfoDao lgDao = new LanguageInfoDao();
BusinessInfoDao biDao = new BusinessInfoDao();
BusinessInfo biInfo = new BusinessInfo();
String message = "" ;
//获取所有语种
List<LanguageInfo> languageInfoList = lgDao.getAll();
//获取六大业务
List<ChannelInfo> channelInfoAllList = clDao.getSubListByParentIdLanguageId(1,2,0,1000);

//获取操作表示符号
String cate = request.getParameter("cate");

int biId = StringUtils.isNotBlank(request.getParameter("biId")) ? Integer.parseInt(request.getParameter("biId")) : 0 ;
int languageId = StringUtils.isNotBlank(request.getParameter("languageId")) ? Integer.parseInt(request.getParameter("languageId")) : 0 ;
int channelId = StringUtils.isNotBlank(request.getParameter("channelId")) ? Integer.parseInt(request.getParameter("channelId")) : 0 ;

if(StringUtils.equals("showUpdate",cate)){
	cate = "update" ;
	biInfo = biDao.getBIByBID(biId);
}
else if(StringUtils.equals("update",cate)){
	
	String content = request.getParameter("content");
	
	BusinessInfo info = new BusinessInfo();
	info.setBiId(biId);
	info.setLanguageId(languageId);
	info.setChannelId(channelId);
	info.setBiContent(content);
	
	if(biDao.udpateBusiness(info)){
		message = "操作成功!" ;
	}else{
		message = "操作失败!" ;

	}
	request.setAttribute("message",message);
	getServletContext().getRequestDispatcher("/admin/common/message.jsp").forward(request,response);
	return ;
}
else{
	request.setAttribute("message","无效点击");
	getServletContext().getRequestDispatcher("/admin/common/message.jsp").forward(request,response);
	return ;
}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<LINK href="../../styleAdmin/css/portalinabox.css" type="text/css" rel="stylesheet">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<title>文章内容管理--修改</title>
<script type="text/javascript">
	function checkForm(){
		var errors = "" ;
		if(document.getElementById("languageId").value == "" ){
			errors += "语种不能为空<br/>" ;
		}
		if(document.getElementById("channelId").value == "" ){
			errors += "栏目不能为空<br/>" ;
		}
		if(document.getElementById("content").value == "" ){
			errors += "内容不能为空<br/>" ;
		}
		if(errors.length > 0){
			document.getElementById('errors').innerHTML = "<font color='red' size='12'>" + errors  + "</font>" ;
			return ;
		} 
		document.myform.submit();
	}
</script>
</head>
<body bottomMargin="0" leftMargin="0" rightMargin="0" topmargin="0">
<form name="myform" method="post" action="edit.jsp">
<%@include file="../common/navigate.jsp" %>
<input type="hidden" id="biId" name="biId" value="<%=biId %>"/>
<input type="hidden" id="cate" name="cate" value="<%=cate%>"/>
<table width="90%" border="0" align="center" cellPadding="0" cellSpacing="0" style="margin-top:5px;">
 <tr><td align="center" colspan="2"><div id="errors"></div></td></tr>
 <tr>
	<td vAlign="top" align="center" height="157">
		<table width="10" border="1" class="mainFunctionTable"  cellpadding="0" cellspacing="1">
        	<tr height="25" class="pLabel">
            	<td colspan="2" class="td_nwarpstyle" align="left">&nbsp;&nbsp;业务概况描述--修改业务介绍</td>
            </tr>
			<tr>
         		<td align="center" width="10%">语言种类</td>
         		<td align="left">
         			<select name="languageId" id="languageId" id="languageId">
         				<option value="">请选择</option>
						<%for(LanguageInfo lgSel : languageInfoList){ %>
							<option value="<%=lgSel.getId()%>" <%= lgSel.getId() == biInfo.getLanguageId() ? "selected" : ""  %>><%=lgSel.getName() %></option>
						<%} %>
         			</select>
         			&nbsp;&nbsp;<font color='red'>*</font>
         		</td>
    		 </tr>
			 <tr>
         		<td align="center" width="10%">栏目</td>
         		<td align="left">
					<select name="channelId" id="channelId" id="channelId">
         				<option value="">请选择</option>
						<%for(ChannelInfo clSel : channelInfoAllList){ %>
							<option value="<%=clSel.getChannelId()%>" <%= clSel.getChannelId() == biInfo.getChannelId() ? "selected" : ""  %>><%=clSel.getChannelName() %></option>
						<%} %>
         			</select>
         			&nbsp;&nbsp;<font color='red'>*</font>
				</td>
    		</tr>
			<tr>
         		<td align="center" width="10%">内容</td>
         		<td align="left"><FCK:editor height="380" instanceName="content" value="<%=biInfo.getBiContent() %>"></FCK:editor></td>
    		</tr>
            <tr align="left">
              <td align="center" colspan="2">
	              <a href="javascript:checkForm();"><img src="../../styleAdmin/images/button/save.gif" border=0></a>
	              &nbsp;&nbsp;
			      <a href="list.jsp"><img src="../../styleAdmin/images/button/exit.gif" border=0></a> 
              </td>
            </tr>
          </table>
      </td>
  </tr>
</table>
</form>
</body>
</html>